<template>
  <!-- 添加或修改笔记对话框 -->
  <el-dialog v-if="newOpen" :title="note.title" :visible.sync="newOpen" append-to-body :fullscreen="!fullscreen"
             @close="close"
  >
    <Music :audioSrcs="note.content" v-if="item.classify===105 && newOpen"></Music>
    <img v-else-if="note.classify===110" :src="image" style="width: 100%"/>
    <video v-else-if="note.classify===111" :src="image" :controls="videoOptions.controls" style="width: 100%"></video>
    <div v-html="note.content" v-else class="textIndent"></div>
  </el-dialog>
</template>

<script>
import Music from '@/views/note/note/music'
import {Base64} from 'js-base64'
export default {
  name: 'NoteInfo',
  components: {Music},
  props: ['item', 'open'],
  data() {
    return {
      arr1: [105],
      fullscreen: true,
      elCardStyle: ' padding: 0px;',
      image: '',
      note: {},
      newOpen: false,
      videoOptions: {
        controls: true
      }
    }
  },
  created() {
    this.note = {...this.item}
    console.log(this.note)
    this.note.content = this.note.content ? Base64.decode(this.note.content) : null
    if (this.note.classify === 110 || this.note.classify === 111) {
      this.image = 'http://' + new URL(window.location.href).hostname + ':' + new URL(window.location.href).port + this.note.content
    } else {

    }
    this.newOpen = this.open
  },
  methods: {
    //查找某个元素是否存在
    find(arr, val) {
      let value = arr.indexOf(val)
      // console.log("find(arr,val){",value!==-1)
      return value !== -1
    },   //查找某个元素是否存在
    close() {
      console.log('close')
      this.$emit('close')
    }
  }
}
</script>

<style scoped>
.textIndent > p {
  text-indent: 2em;
}
</style>
